package com.aier.common.common;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

public class CookieCommon {

    // 根据指定值写入cookie
    public static boolean writeCookie(HttpServletResponse response, String key,
            String value, String domain, Integer time) {
        // 创建cookie
        Cookie c = new Cookie(key, value);
        // 保存时间
        c.setMaxAge(time);
        // 主域
        c.setDomain(domain);
        c.setPath("/");
        // 添加cookie
        response.addCookie(c);
        return true;
    }
    
}
